<f:view xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:sf="http://www.springframework.org/tags/faces"
  contentType="text/html" encoding="UTF-8">

  <sf:resourceGroup>
    <sf:resource path="/css/header.css" />
  </sf:resourceGroup>

  <div id="header">
    <!-- Background of header -->
    <div id="headerBackground" />

    <!-- Left elements of header -->
    <div id="headerLeft">
      <div class="headerLogoJAWP">
        <img src="../images/Projet2.png" height="60px" />
      </div>

      <span class="headerTitle" title="Java Amazon Webstore Project">
        <span class="headerJ">J</span>AWP
      </span> <span class="headerSubTitle"> <span class="headerJ">Java</span>
        Amazon Webstore Project
      </span>

      <div class="headerDate">#{appInfo.date} :</div>
    </div>

    <!-- Right elements of header -->
    <div id="headerRight">
      <c:if test="${empty currentUser.name}">
        <div class="headerRow1">You are currently not logged</div>
      </c:if>

      <c:if test="${not empty currentUser.name}">

        <c:set var="role" scope="view" value="xxx" />
        <c:if test="${currentUser.authorities[0] == 'ROLE_ADMIN'}">
          <c:set var="role" scope="view" value="Admin" />
        </c:if>
        <c:if test="${currentUser.authorities[0] == 'ROLE_BUYER'}">
          <c:set var="role" scope="view" value="Buyer" />
        </c:if>
        <c:if test="${currentUser.authorities[0] == 'ROLE_USER'}">
          <c:set var="role" scope="view" value="Client" />
        </c:if>

        <h:form class="headerRow1">
          <h:outputText value="You are connected : " />

          <h:commandLink action="profil"
            title="Click here for edit your profil">
            <span class="headerUserName">${currentUser.name}
              (#{role})</span>
          </h:commandLink>
            : <a href="${request.contextPath}/flow/logout">Logout</a>
        </h:form>

        <h:form class="headerRow3">
          <h:commandLink action="cart"
            title="Click here for look your cart">
            <span class="headerCart">Your cart <h:graphicImage
                value="../images/cart.png" witdh="30px"
                class="headerImgCart" height="30px" alt="cart" /></span>

          </h:commandLink>
        </h:form>

        <h:form class="headerRow2">
          <h:panelGrid border="0" columns="2" class="headerSearch">
            <h:inputText required="false"
              value="#{conversationScope.search}" id="search" size="40" />
            <h:commandButton action="search" value="Search" class="" />
          </h:panelGrid>
        </h:form>
      </c:if>
    </div>
  </div>
</f:view>
